package com.digital.smartgrow.service.title;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.WorkExperiencesMapper;
import com.digital.smartgrow.dto.title.WorkExperience;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class WorkExperiencesServiceImpl implements WorkExperienceService{

    @Autowired
    WorkExperiencesMapper workExperiencesMapper;

    @Override
    @Transactional
    public List<WorkExperience> findList(WorkExperience workExperience) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard", workExperience.getIdcard());
        queryWrapper.eq("status", 0);
        return workExperiencesMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void deleteCommend(WorkExperience workExperience) {
        WorkExperience workExperience1 = new WorkExperience();
        Date date = new Date();
        workExperience1.setStatus(1).setId(workExperience.getId()).setTime(date);
        workExperiencesMapper.updateById(workExperience1);
    }
}
